<?php
/**
 * Created by PhpStorm.
 * User: czw
 * Date: 2018/7/11
 * Time: 14:59
 */
namespace app\common\model;

use app\lib\exception\CreateException;
use think\Db;

class Source extends BaseModel
{
    public static function getAll(){
        return self::select();
    }
    public static function createOne($data){
        $res = (new self())->allowField(true)->save($data);
        if(!$res) throw (new CreateException());
    }
    public static function updateOne($id,$data){
        $res = (new self())->allowField(true)->where('id='.$id)->update($data);
        if(!$res) throw (new CreateException());
    }
    public static function deleteOne($id){
        return self::destroy($id);
    }
//    public function getAuthListById($id){
//        $roles = Db::table('role')->where('admin_id='.$id)->field('id')->select();
//        $role_ids = implode(',',$roles);
//        return self::where('role_id in "'.$role_ids.'"')->select();
//
//    }
}